import { defineStore } from 'pinia'

export const useConfigStore = defineStore('config', {
  state: () => ({
    invariantParams: {
      data_path: './data/',
      root: 'ndb_cifar10_data/',
      pchoice: 1,
      value_steps: 5,
      node_id: 1,
      save_json: 'answer',
      model_save_path: './mymodel',
      k: 3,
      no_models: 3,
      address: '127.0.0.1:8080',
      eta: 2,
      alpha: 1.0,
      poison_label: 2,
      poisoning_per_batch: 4,
      prop: 0.6,
    },
    dataParams: {
      type: 'cifar',
      subsize_rate: 0.05,
      one_image_path: '111.png',
    },
    encryptionParams: {
      choice: -1,
      C: 1000,
      sigma: 0.01,
      q: 0.2,
      w: 2,
      feature_num: 30,
    },
    modelParams: {
      model_name: 'resnet50',
      model_save_name: 'test',
      batch_size: 100,
      lr: 0.1,
      momentum: 0.9,
      lambda_: 0.1,
      dp: true,
      global_epochs: 5,
      local_epochs: 3,
      min_available_clients: 2,
      increment: '',
      is_increment: false,
    },
  }),
  actions: {
    updateInvariantParams(newParams) {
      this.invariantParams = { ...this.invariantParams, ...newParams }
    },
    updateDataParams(newParams) {
      this.dataParams = { ...this.dataParams, ...newParams }
    },
    updateEncryptionParams(newParams) {
      this.encryptionParams = { ...this.encryptionParams, ...newParams }
    },
    updateModelParams(newParams) {
      this.modelParams = { ...this.modelParams, ...newParams }
    },
  },
})
